
/**
 * A Bank class
 * @author Sanjeev Kamboj, Travis Drake
 * Assignment 1
 *
 */
public class CreditCard 
{
	/** The last credit card number used*/
	private static int fLastCreditCardNumber;
	
	/**The account number that this card is connected to*/
	private int fAccountConnectedTo;
	
	/** The CreditCard number of this credit card*/
	private int fCreditCardNumber;
	
	/** The owner of this account*/
	private Person my_owner;
	
	/** The limit of this credit card*/
	private double fLimit; // you cannot spend more than this limit
	
	/** The balance of this credit card*/
	private double fBalance;
	
	/**
	 * Constructs a CreditCard.
	 * 
	 * @param the_owner The owner of this credit card.
	 */
	public CreditCard(final Person the_owner)
	{
		this(the_owner, 2500);
	}
	
	/**
	 * Constructs a Credit Card.
	 * 
	 * @param the_owner The owner of this credit card.
	 * @param limit The limit of teh credit card.
	 */
	public CreditCard(final Person the_owner, final double limit)
	{
		my_owner = the_owner;
		fLimit = limit;
		fBalance = 0;
		fLastCreditCardNumber = 1;
		fAccountConnectedTo = -1;
	}
	
	
	/**
	 * Method to make payments off account
	 * @param amount The amount to pay off.
	 * @return A poolean for if teh paymetn was made.
	 */
	public boolean pay(double amount)
	{
		boolean is_payed = false;
		if((fBalance - amount) > -fLimit)
		{
			fBalance -= amount;
			is_payed = true;
		}
		return is_payed;
	}
	
	/**
	 * Getter Method for the balance
	 * 
	 * @return The current balance.
	 */
	public double getBalance()
	{
		return fBalance;
	}
	
	/**
	 * Sets the balance of the card.
	 * @param the_balance The balance to set 
	 */
	public void setBalance(final int the_balance) {
		fBalance = the_balance;
	}
	
	/**
	 * Sets the Credit Card Number to the one passed in 
	 * @param the_num The number to set this acct number to.
	 */
	public void setCreditCardNumber(final int the_num) {
		fCreditCardNumber = the_num;
	}
	
	/**
	 * Sets the account number to the next one available
	 */
	public void setNextCreditCardNumber() {
		fCreditCardNumber = fLastCreditCardNumber;
		fLastCreditCardNumber++;
	}
	
	/**
	 * Getter method for the credit card number
	 * @return The credit card number 
	 */
	public int getCreditCardNum() {
		return fCreditCardNumber;
	}
	
	/**
	 * Sets the Account Connected Number to the number given
	 * @param the_acct The account to set
	 */
	public void setAccountConnectedTo(final int the_acct) {
		fAccountConnectedTo = the_acct;
	}
	
	/**
	 * Getter for the AccountConnectedNumber
	 * @return the account that this card is linked to.
	 */
	public int getAcctConnectedTo() {
		return fAccountConnectedTo;
	}
	
	/**
	 * Getter Method for the Owner of this account
	 * @return The owner of this account.
	 */
	public Person getOwner() {
		return my_owner;
	}
}
